const uuidV4 = require('uuid/v4'); //随机数工具uuid
const moment = require('moment');
moment.locale('zh-cn');

module.exports = {
    //秒转时间
    secsToDate: (secs) => {
        let num = 'null'; //定义时间戳
        if (!parseInt(secs)) {
            num = ''; //值为undefined、null、NaN、0
        } else if (secs == 'undefined' || secs == 'null' || secs == 'NaN' || !/\S/.test(secs)) {
            num = ''; //值为"undefined"、"null"、"NaN"、空
        } else {
            // num = new Date(parseInt(secs) * 1000).toLocaleString("zh");
            num = moment(new Date(parseInt(secs) * 1000)).format('YYYY-MM-DD HH:mm:ss');
        };
        return num;
    },

    //时间转秒
    dateToSecs: (date) => {
        let dateStr = String(date);
        return (Date.parse(new Date(dateStr)) / 1000).toString();
    },

};